package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.query.QuestionAdminPageQuery;
import com.tianji.learning.domain.vo.QuestionAdminVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/admin/questions")
@RequiredArgsConstructor
public class InteractionAdminQuestionController {
    private final IInteractionQuestionService interactionQuestionService;

    /**
     * 管理端-分页查询互动问题
     *
     * @param page
     * @return
     */
    @ApiOperation("管理端-分页查询互动问题")
    @GetMapping("/page")
    public PageDTO<QuestionAdminVO> pageAdminQuestions(QuestionAdminPageQuery page) {
        return interactionQuestionService.pageAdminQuestions(page);
    }

    /**
     * 管理端-根据id查询问题详情
     *
     * @param id
     * @return
     */
    @ApiOperation("管理端-根据id查询问题详情")
    @GetMapping("/{id}")
    public QuestionAdminVO queryQuestionInfoById(@PathVariable Long id) {
        log.info("查询问题详情：{}", id);
        return interactionQuestionService.queryQuestionInfoById(id);
    }

    /**
     * 管理端-隐藏或显示问题
     *
     * @param id
     * @param hidden
     */
    @ApiOperation("管理端-隐藏或显示问题")
    @PutMapping("/{id}/hidden/{hidden}")
    public void updateQuestionHidden(@PathVariable Long id, @PathVariable Boolean hidden) {
        log.info("问题id：{},隐藏或显示:{}", id, hidden);
        interactionQuestionService.updateQuestionHidden(id, hidden);
    }
}
